import { useEffect, useState } from "react";

const ChatApi = {};
function useFriendStatus(id) {
    const [isOnline, setIsOnline] = useState(null);
    function handleStatusChange(status) {
        setIsOnline(status);
    }
    useEffect(() => {
        ChatApi.sun(id, handleStatusChange);
        return () => {
            ChatApi.unsub(id, handleStatusChange);
        };
    }); //
    return isOnline;
}

export default useFriendStatus;
